import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main2 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        String inputStr=in.nextLine();
        String[] data=inputStr.split(",");
        //首先两两组合
        List<String> combineStrLiust=new ArrayList<>();
        for (int i=0;i<data.length;i++){
            for(int j=i+1;j<data.length;j++){
                String combineEach=data[i]+","+data[j];
                combineStrLiust.add(combineEach);
            }
        }
        List<String> conditionCombine=new ArrayList<>();
        //再将两两组合的数据与第三个组合计算所有组合
        for(int i=0;i<combineStrLiust.size();i++){
             String eachCombine=combineStrLiust.get(i);
             for (int j=0;j<data.length;j++){
                 String orgData=data[j];
                 String c=eachCombine+","+orgData;
                 conditionCombine.add(c);
             }
        }
        String[] sInit=conditionCombine.get(0).split(",");
        String numInitStr="";
        for (int j=0;j<sInit.length;j++){
            numInitStr+=sInit[j];
        }
        Long min=Long.parseLong(numInitStr);
        for (int i=0;i<conditionCombine.size();i++){
           String[] s=conditionCombine.get(i).split(",");
           String numStr="";
           for (int j=0;j<s.length;j++){
               numStr+=s[j];
           }
           Long num=Long.parseLong(numStr);
           if(num<min){
               min=num;
           }
        }
        System.out.println(min);
    }
}

